package fr.pascal.idComposite1;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import fr.pascal.util.HibernateUtil;

public class App {
	public static void main(String[] args) {
		Session session = HibernateUtil.getSession();
		Transaction tx = session.beginTransaction();
		
		Contact c = new Contact("hector", "berlioz");
		c.setAge(52);
		c.setPays("france");
		session.save(c);

		List<Contact> contacts = session.createQuery("from Contact").list();
		for (Iterator<Contact> it = contacts.iterator(); it.hasNext();) {
			Contact contact = it.next();
			System.out.println(contact.getPays() + " - " + contact.getAge());
		}

		tx.commit();
		session.close();
	}
}
